package com.wjx.happensbefore.monitorlock;

import com.wjx.happensbefore.Utils;

public class WithoutMonitorLockRule {
    private static boolean stop = false;

    public static void main(String[] args) {
        Thread updater = new Thread(new Runnable() {
            @Override
            public void run() {
                Utils.sleep(1000);
                stop = true;
                System.out.println("updater set stop true");
            }
        }, "updater");

        Thread getter = new Thread(new Runnable() {
            @Override
            public void run() {
                while (true) {
                    if (stop) {
                        System.out.println("getter stopped");
                        break;
                    }
                }
            }
        }, "getter");
        getter.start();
        updater.start();
    }

}
